import { request } from './request'
import type { UserInfo, PaginatedResponse } from '@/types'

// 获取用户列表
export const getUsers = (params: { page: number; page_size: number }) => {
  return request<PaginatedResponse<UserInfo>>({
    url: '/admin/users',
    method: 'get',
    params
  })
}

// 获取用户详情
export const getUser = (id: number) => {
  return request<UserInfo>({
    url: `/admin/users/${id}`,
    method: 'get'
  })
}

// 创建用户
export const createUser = (data: any) => {
  return request<UserInfo>({
    url: '/admin/users',
    method: 'post',
    data
  })
}

// 更新用户
export const updateUser = (id: number, data: any) => {
  return request<UserInfo>({
    url: `/admin/users/${id}`,
    method: 'put',
    data
  })
}

// 删除用户
export const deleteUser = (id: number) => {
  return request({
    url: `/admin/users/${id}`,
    method: 'delete'
  })
}

